]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
volume: Clarify some code
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 14 Sep 2019 12:33:09 +0000 (14:33 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 15 Sep 2019 14:02:45 +0000 (16:02 +0200)
We have more idiomatic ways to check whether any element fullfills
some condition than breaking out of a loop.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/731

js/ui/status/volume.js

index 21968107d0f7a580be9a0864e22cec60a6072b27..db8e5a1f1dcfcc80801f640eeb65d0e193dedc17 100644 (file)
@@ -259,18 +259,17 @@ var InputStreamSlider = class extends StreamSlider {
     _maybeShowInput() {
         // only show input widgets if any application is recording audio
         let showInput = false;
-        let recordingApps = this._control.get_source_outputs();
-        if (this._stream && recordingApps) {
-            for (let i = 0; i < recordingApps.length; i++) {
-                let outputStream = recordingApps[i];
-                let id = outputStream.get_application_id();
-                // but skip gnome-volume-control and pavucontrol
-                // (that appear as recording because they show the input level)
-                if (!id || (id != 'org.gnome.VolumeControl' && id != 'org.PulseAudio.pavucontrol')) {
-                    showInput = true;
-                    break;
-                }
-            }
+        if (this._stream) {
+            // skip gnome-volume-control and pavucontrol which appear
+            // as recording because they show the input level
+            let skippedApps = [
+                'org.gnome.VolumeControl',
+                'org.PulseAudio.pavucontrol'
+            ];
+
+            showInput = this._control.get_source_outputs().some(output => {
+                return !skippedApps.includes(output.get_application_id());
+            });
         }
 
         this._showInput = showInput;